var utils_db = require("../utils/mysql")
console.log(utils_db)
class TUser{
    constructor(){
        this.dbCode = "hosdb";
    }
    checkLogin(userCode  , userPwd){
        var me = this;
        var loginRes = {
            status :0 ,
            data:{}
        }
        return new Promise((success,fail)=>{
            try {
                var sql = "select * from T_User where userCode=:userCode and userPwd =:userPwd";
                var params = {
                    userCode: userCode ,
                    userPwd : userPwd
                }
                var clientItem = utils_db.db.getItem(me.dbCode);
                clientItem.query(sql , params).then(_res=>{
                    if (_res && _res!=null && _res.length>0){
                        loginRes.status = 1;
                        loginRes.data = _res[0];
                    }
                    success(loginRes)
                    console.log(_res)
                });
                
            } catch (error) {
                console.log(error);
                success(loginRes)
            }
        })
    }
}

console.log('load user modal.')
var user = new TUser()

module.exports = {
    user:user
}

/*
user.checkLogin('zhangs', '123456').then(_loginRes=>{
    console.log(_loginRes)
})
*/

